import static org.junit.Assert.*;

import java.util.List;

import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.zanateh.wargame.game.*;
import org.zanateh.wargame.game.hexagon.Hexagon;
import org.zanateh.wargame.game.hexagon.HexagonFactory;
import org.zanateh.wargame.game.hexagon.HexagonFactory.HexagonType;
import org.zanateh.wargame.game.piece.IHexagonOccupant;

public class HexagonTest {
	
	class TestOccupant implements IHexagonOccupant {
		
	}
	
	@Test
	public void ContentsTest() {
		Hexagon hexagon = HexagonFactory.createHexagon(HexagonType.TEST);
		
		TestOccupant testOccupant1 = new TestOccupant();
		TestOccupant testOccupant2 = new TestOccupant();
		hexagon.addOccupant(testOccupant1);
		hexagon.addOccupant(testOccupant2);
		
		List<IHexagonOccupant> occupants = hexagon.getOccupants();
		Assert.assertTrue(occupants.contains(testOccupant1));
		Assert.assertTrue(occupants.contains(testOccupant2));
		Assert.assertEquals(2, occupants.size());
	}
	
	@Test(expected=IllegalArgumentException.class)
	public void ReaddOccupants()
	{
		Hexagon hexagon = HexagonFactory.createHexagon(HexagonType.TEST);
		TestOccupant testOccupant1 = new TestOccupant();
		
		hexagon.addOccupant(testOccupant1);
		hexagon.addOccupant(testOccupant1);
	}
	
	@Test
	public void RemoveOccupants() {
		Hexagon hexagon = HexagonFactory.createHexagon(HexagonType.TEST);
		TestOccupant testOccupant1 = new TestOccupant();
		
		hexagon.addOccupant(testOccupant1);
		hexagon.removeOccupant(testOccupant1);
		Assert.assertEquals(0, hexagon.getOccupants().size());
	}
}
